<template>
    <div>
        <el-dialog
            v-model="toFunctionVisible"
            :destroy-on-close="true"
            :close-on-click-modal="false"
            title="分配功能"
            @close="handleClose"
        >
            <el-transfer v-model="assignFunctions" :data="allFunctions" :titles="['未分配', '已分配']" />
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="toFunctionVisible = false"
                        >取消</el-button
                    >
                    <el-button type="primary" @click="handleOK">
                        确定
                    </el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
<script setup>
import { ElMessage } from "element-plus";
import { defineEmits, ref } from "vue";
import { Plus } from '@element-plus/icons-vue'
import { storeToRefs } from "pinia";
import { useRoleStore } from "../../../stores/role";
import { assignRoleFunction } from "../../../services/role";
const roleStore = useRoleStore();
const {roleId,toFunctionVisible,allFunctions,assignFunctions} = storeToRefs(roleStore);

const formLabelWidth = ref(100);
const handleClose = () => {};
const handleOK = async () => {
    await assignRoleFunction(roleId.value,assignFunctions.value);
    toFunctionVisible.value = false;
};
</script>
<style scoped>
.add-btn {
    display: flex;
    justify-content: flex-end;
}
</style>
